package com.fullhome8.cn.wanghongweb;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * 在线api
 * @author: yuanxuefeng
 * @version: 2017/8/18
 */
@Configuration
@EnableSwagger2
@EnableAutoConfiguration
@Profile({"dev", "local"})
public class Swagger2 {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                    .apiInfo(apiInfo())
                    .select()
                    .apis(RequestHandlerSelectors.basePackage("com.fullhome8.cn.wanghongweb.controller"))
                    .paths(PathSelectors.any())
                    .build();

    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("wanghong-web api")
                .description("Restful")
                .termsOfServiceUrl("http://blog.didispace.com/")
                .contact("face-team")
                .version("1.0")
                .build();
    }
}
